import Vue from 'vue'
import VueRouter from 'vue-router'


Vue.use(VueRouter)

const routes = [{
    path: '/',
    redirect: "/main"
  },

  // 主要布局 含底部导航
  {
    path: '/main',
    redirect: '/main/home',
    component: () => import( /* webpackChunkName: "main" */ '../layout/Main.vue'),
    children: [{
        // 图书列表页面
        path: 'home',
        name: 'Home',
        component: () => import( /* webpackChunkName: "home" */ '../views/Home.vue'),
      },

      {
        // 我的书架
        path: 'my',
        main: 'My',
        component: () => import( /* webpackChunkName: "my" */ '../views/My.vue'),
      }
    ]
  },

  // 单页面布局 不含底部导航
  {
    path: '/page',
    name: 'Page',
    component: () => import( /* webpackChunkName: "page" */ '../layout/Page.vue'),
    children: [{
        path: 'login',
        name: 'Login',
        component: () => import( /* webpackChunkName: "login" */ '../views/Login.vue'),
      },
      {
        path: 'detail/:id',
        name: 'Detail',
        component: () => import( /* webpackChunkName: "detail" */ '../views/Detail.vue'),
      }

    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router